import { createRouter, createWebHashHistory } from "vue-router";
import globalRoutes from "./globalRoutes";
import mainRoutes from "./mainRoutes";

const router = createRouter({
    history: createWebHashHistory(),
    scrollBehavior: () => ({ y: 0 }),
    isAddDynamicMenuRoutes: false, // 是否已经添加动态(菜单)路由
    routes: globalRoutes.concat(mainRoutes),
});
// router.beforeEach((to, from, next) => {
//     console.log("from" + from.path + "....to" + to.path);
//
//     if (
//         to.matched.length === 0 ||
//         globalRoutes.findIndex((route) => (route.path = to.path)) === -1
//     ) {
//         console.log("404");
//         // 路由不存在
//         next("/404"); // 跳转到404页面
//     } else {
//         next(); // 路由存在，正常跳转
//         console.log("normal");
//     }
// });

export default router;
